import api from "../api/index";
import Axios from '../utils/axios'

export interface queryObject{
    name?:string,
    limit?:number,
    page?:number,
    spu_type_id?:string,
}

//商品表
//商品查询所有
function SpuAll(){
    return Axios.get(api.shopCategory.Spu_All)
}
//商品表修改
function updateShop(obj:object){
    return Axios.post(api.shopCategory.Spu_Update,obj)
}
//根据id删除
function deleteShop(id:any){
    return Axios.get(api.shopCategory.Spu_Delete+id)
}
//商品添加
function addShop(obj:object){
    console.log("请求传参:",obj);
    return Axios.post(api.shopCategory.Spu_Add,obj)
}
//根据id查询
function getShopById(id:any){
    return Axios.get(api.shopCategory.Spu_FindById+id)
}
//条件查询广告
function queryShop(obj:queryObject){
    let txtData="?"
    for(let key in obj){
        txtData += `${key}=${obj[key]}&`
    }
    txtData=txtData.slice(0,txtData.length-1)
    console.log("请求参数:",txtData);
    return Axios.get(api.shopCategory.Spu_Query,{params:obj})
    
}
export default{
    SpuAll,
    updateShop,
    deleteShop,
    addShop,
    getShopById,
    queryShop
}